package com.pubinfo.passbook.engine.process.variable.medicine;

import com.pubinfo.passbook.common.mapper.TRuleUserWiteoffMapper;
import com.pubinfo.passbook.common.model.dto.witeoff.MedicineOnJobOrRetireDTO;
import com.pubinfo.passbook.common.model.ruler.PayInformation;
import com.pubinfo.passbook.common.service.dubbo.DubboService;
import com.pubinfo.passbook.common.service.ruler.InformationService;
import com.pubinfo.passbook.engine.utils.ApplicationContextUilts;

import java.math.BigDecimal;
import java.util.List;

/**
 * 门诊历史报账金额
 *
 * @author zhouch
 * @date 2022/1/25 8:28
 */
public class HistoryNormalSumProcessor extends MedicineVariableProcessor {

    DubboService dubboService;

    TRuleUserWiteoffMapper witeoffMapper;

    @Override
    public String getName() {
        return "门诊历史报账金额";
    }

    public HistoryNormalSumProcessor() {
        dubboService = ApplicationContextUilts.getBean(DubboService.class);
        witeoffMapper = ApplicationContextUilts.getBean(TRuleUserWiteoffMapper.class);
    }

    @Override
    public BigDecimal get(MedicineOnJobOrRetireDTO data) {
        List<PayInformation> payInformations = cache.getPayInformationData();

        PayInformation pay = payInformations.get(0);

        //报账人的身份证号
        String idNo = pay.getPayerPartyCode();


        String acct = dubboService.getPersonsDetailByAcct(idNo);

        return witeoffMapper.countSumByAcct(acct, 330601);
    }
}
